using MuYue.Log;
using System;
using System.Diagnostics;
namespace MuYue.Common
{
	public class Profile : IDisposable
	{
		private readonly Stopwatch watch;
		private readonly string message;
		private Profile(string message)
		{
			this.watch = new Stopwatch();
			this.watch.Start();
			this.message = message;
		}
		public void Dispose()
		{
			this.watch.Stop();
			double num = 1000.0 * (double)this.watch.ElapsedTicks / (double)Stopwatch.Frequency;
			LogService.Debug(string.Format("{0}用时：{1:0.00} ms", this.message, num));
		}
		public static IDisposable Step(string message)
		{
			return new Profile(message);
		}
		public static T Inline<T>(string message, Func<T> func)
		{
			T result;
			using (new Profile(message))
			{
				result = func();
			}
			return result;
		}
	}
}
